package com.googlecode.horncomb.web.spring.mvc.support;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;

public class StatusMappingExceptionResolver extends
		SimpleMappingExceptionResolver {
	private Map<String, String> statusCodeMap = new HashMap<String, String>();

	@Override
	protected Integer determineStatusCode(HttpServletRequest request,
			String viewName) {
		if (statusCodeMap.containsKey(viewName)) {
			return new Integer(statusCodeMap.get(viewName));
		} else {
			return super.determineStatusCode(request, viewName);
		}
	}

	/**
	 * @param statusCodeMap
	 *            the statusCodeMap to set
	 */
	public void setStatusCodeMap(Map<String, String> statusCodeMap) {
		this.statusCodeMap = statusCodeMap;
	}
}
